package org.liulinlin.sejw.db;

import java.sql.*;

public class Commission {
	private String id;
	private Customer sender;
	private Customer receiver;
	private Customer notifier;
	private Goods goods;
	private boolean LCL;
	private String transportTerms;
	private ShipComInfo shipComInfo;
	private String receiveLoc;
	private String route;
	private String departure;
	private String destination;
	private java.sql.Date receiveTime;
	private String receiveTimeString;
	private java.sql.Date departureTime;
	private String departureTimeString;
	private java.sql.Date arriveTime;
	private String arriveTimeString;
	private RouteRequest routeRequest;
	private boolean multiShip;
	private boolean multiSchedule;
	private boolean timeChangable;
	private java.sql.Date timeChanged;
	private String timeChangedString;
	private CommitedService commitedService;
	private boolean prePay;
	private String otherPay;
	private LetterOfCredit letterOfCredit;
	private boolean shipComBOL;
	private boolean FABOL;
	private boolean shipCertificate;
	private String MORD;
	private String shippingDocuments;
	private String specialRequest;
	private String comments;
	private java.sql.Date senderSignTime;
	private String senderSignTimeString;
	private java.sql.Date FASignTime;
	private String FASignTimeString;
	
	public Commission() {
		
	}
	public Commission(String id) {
		DBConnectionManager connMgr = DBConnectionManager.getInstance();
		Connection con = connMgr.getConnection("shipping_export");
		if (con == null) {
			System.out.println("Commission不能获得数据库连接");
			return;
		}
		
		try {
			Statement stmt = con.createStatement();
			ResultSet rs = stmt.executeQuery("select * from Commission where Comm_ID = '" + id + "'");
		
			rs.next();
			this.id = id;
			sender = new Customer(rs.getString("Comm_Sender"));
			receiver = new Customer(rs.getString("Comm_Receiver"));
			notifier = new Customer(rs.getString("Comm_Notifier"));
			goods = new Goods(rs.getString("Comm_Goods"));
			LCL = rs.getBoolean("Comm_LCL");
			transportTerms = rs.getString("Comm_TransportTerms");
			shipComInfo = new ShipComInfo(rs.getString("ShipCom_ID"));
			receiveLoc = rs.getString("Comm_ReceiveLoc");
			route = rs.getString("Comm_Route");
			departure = rs.getString("Comm_Departure");
			destination = rs.getString("Comm_Destination");
			receiveTime = rs.getDate("Comm_ReceiveTime");
			receiveTimeString = receiveTime.toString();
			departureTime = rs.getDate("Comm_DepartureTime");
			departureTimeString = departureTime.toString();
			arriveTime = rs.getDate("Comm_ArriveTime");
			arriveTimeString = arriveTime.toString();
			routeRequest = new RouteRequest(rs.getInt("RR_ID"));
			multiShip = rs.getBoolean("Comm_MultiShip");
			multiSchedule = rs.getBoolean("Comm_MultiSchedule");
			timeChangable = rs.getBoolean("Comm_TimeChangable");
			timeChanged = rs.getDate("Comm_TimeChanged");
			timeChangedString = timeChanged == null ? null : timeChanged.toString();
			commitedService = new CommitedService(rs.getInt("CS_ID"));
			prePay = rs.getBoolean("Comm_PrePay");
			otherPay = rs.getString("Comm_OtherPay");
			letterOfCredit = new LetterOfCredit(rs.getString("LOC_ID"));
			shipComBOL = rs.getBoolean("Comm_ShipComBOL");
			FABOL = rs.getBoolean("Comm_FABOL");
			shipCertificate = rs.getBoolean("Comm_ShipCertificate");
			MORD = rs.getString("Comm_MORD");
			shippingDocuments = rs.getString("Comm_ShippingDocuments");
			specialRequest = rs.getString("Comm_SpecialRequest");
			comments = rs.getString("Comm_Comments");
			senderSignTime = rs.getDate("Comm_SenderSignTime");
			senderSignTimeString = senderSignTime.toString();
			FASignTime = rs.getDate("Comm_FASignTime");
			FASignTimeString = FASignTime.toString();
			
			rs.close();
			stmt.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		
		connMgr.freeConnection("shipping_export", con);
		connMgr.release();
	}
	
	public void setId(String id) {
		this.id = id;
	}
	public void setSender(Customer sender) {
		this.sender = sender;
	}
	public void setReceiver(Customer receiver) {
		this.receiver = receiver;
	}
	public void setNotifier(Customer notifier) {
		this.notifier = notifier;
	}
	public void setGoods(Goods goods) {
		this.goods = goods;
	}
	public void setLCL(boolean LCL) {
		this.LCL = LCL;
	}
	public void setTransportTerms(String transportTerms) {
		this.transportTerms = transportTerms;
	}
	public void setShipComInfo(ShipComInfo shipComInfo) {
		this.shipComInfo = shipComInfo;
	}
	public void setReceiveLoc(String receiveLoc) {
		this.receiveLoc = receiveLoc;
	}
	public void setRoute(String route) {
		this.route = route;
	}
	public void setDeparture(String departure) {
		this.departure = departure;
	}
	public void setDestination(String destination) {
		this.destination = destination;
	}
	public void setReceiveTime(java.sql.Date receiveTime) {
		this.receiveTime = receiveTime;
	}
	public void setReceiveTimeString(String receiveTimeString) {
		this.receiveTimeString = receiveTimeString;
	}
	public void setDepartureTime(java.sql.Date departureTime) {
		this.departureTime = departureTime;
	}
	public void setDepartureTimeString(String departureTimeString) {
		this.departureTimeString = departureTimeString;
	}
	public void setArriveTime(java.sql.Date arriveTime) {
		this.arriveTime = arriveTime;
	}
	public void setArriveTimeString(String arriveTimeString) {
		this.arriveTimeString = arriveTimeString;
	}
	public void setRouteRequest(RouteRequest routeRequest) {
		this.routeRequest = routeRequest;
	}
	public void setMultiShip(boolean multiShip) {
		this.multiShip = multiShip;
	}
	public void setMultiSchedule(boolean multiSchedule) {
		this.multiSchedule = multiSchedule;
	}
	public void setTimeChangable(boolean timeChangable) {
		this.timeChangable = timeChangable;
	}
	public void setTimeChanged(java.sql.Date timeChanged) {
		this.timeChanged = timeChanged;
	}
	public void setTimeChangedString(String timeChangedString) {
		this.timeChangedString = timeChangedString;
	}
	public void setCommitedService(CommitedService commitedService) {
		this.commitedService = commitedService;
	}
	public void setPrePay(boolean prePay) {
		this.prePay = prePay;
	}
	public void setOtherPay(String otherPay) {
		this.otherPay = otherPay;
	}
	public void setLetterOfCredit(LetterOfCredit letterOfCredit) {
		this.letterOfCredit = letterOfCredit;
	}
	public void setShipComBOL(boolean shipComBOL) {
		this.shipComBOL = shipComBOL;
	}
	public void setFABOL(boolean FABOL) {
		this.FABOL = FABOL;
	}
	public void setShipCertificate(boolean shipCertificate) {
		this.shipCertificate = shipCertificate;
	}
	public void setMORD(String MORD) {
		this.MORD = MORD;
	}
	public void setShippingDocuments(String shippingDocuments) {
		this.shippingDocuments = shippingDocuments;
	}
	public void setSpecialRequest(String specialRequest) {
		this.specialRequest = specialRequest;
	}
	public void setComments(String comments) {
		this.comments = comments;
	}
	public void setSenderSignTime(java.sql.Date senderSignTime) {
		this.senderSignTime = senderSignTime;
	}
	public void setSenderSignTimeString(String senderSignTimeString) {
		this.senderSignTimeString = senderSignTimeString;
	}
	public void setFASignTime(java.sql.Date FASignTime) {
		this.FASignTime = FASignTime;
	}
	public void setFASignTimeString(String FASignTimeString) {
		this.FASignTimeString = FASignTimeString;
	}
	
	public String getId() {
		return id;
	}
	public Customer getSender() {
		return sender;
	}
	public Customer getReceiver() {
		return receiver;
	}
	public Customer getNotifier() {
		return notifier;
	}
	public Goods getGoods() {
		return goods;
	}
	public boolean getLCL() {
		return LCL;
	}
	public String getTransportTerms() {
		return transportTerms;
	}
	public ShipComInfo getShipComInfo() {
		return shipComInfo;
	}
	public String getReceiveLoc() {
		return receiveLoc;
	}
	public String getRoute() {
		return route;
	}
	public String getDeparture() {
		return departure;
	}
	public String getDestination() {
		return destination;
	}
	public java.sql.Date getReceiveTime() {
		return receiveTime;
	}
	public String getReceiveTimeString() {
		return receiveTimeString;
	}
	public java.sql.Date getDepartureTime() {
		return departureTime;
	}
	public String getDepartureTimeString() {
		return departureTimeString;
	}
	public java.sql.Date getArriveTime() {
		return arriveTime;
	}
	public String getArriveTimeString() {
		return arriveTimeString;
	}
	public RouteRequest getRouteRequest() {
		return routeRequest;
	}
	public boolean getMultiShip() {
		return multiShip;
	}
	public boolean getMultiSchedule() {
		return multiSchedule;
	}
	public boolean getTimeChangable() {
		return timeChangable;
	}
	public java.sql.Date getTimeChanged() {
		return timeChanged;
	}
	public String getTimeChangedString() {
		return timeChangedString;
	}
	public CommitedService getCommitedService() {
		return commitedService;
	}
	public boolean getPrePay() {
		return prePay;
	}
	public String getOtherPay() {
		return otherPay;
	}
	public LetterOfCredit getLetterOfCredit() {
		return letterOfCredit;
	}
	public boolean getShipComBOL() {
		return shipComBOL;
	}
	public boolean getFABOL() {
		return FABOL;
	}
	public boolean getShipCertificate() {
		return shipCertificate;
	}
	public String getMORD() {
		return MORD;
	}
	public String getShippingDocuments() {
		return shippingDocuments;
	}
	public String getSpecialRequest() {
		return specialRequest;
	}
	public String getComments() {
		return comments;
	}
	public java.sql.Date getSenderSignTime() {
		return senderSignTime;
	}
	public String getSenderSignTimeString() {
		return senderSignTimeString;
	}
	public java.sql.Date getFASignTime() {
		return FASignTime;
	}
	public String getFASignTimeString() {
		return FASignTimeString;
	}
}
